<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link type="text/css" href="/res/app/admin/css/common.css" rel="stylesheet" />
<script type="text/javascript" src="/res/js/lib/jquery.js"></script>
<script type="text/javascript" src="/res/frame/js/t_thickbox.js"></script>
<title>app管理</title>
<script>
//ajax_thickbox_json($('#uri').val(),'/admin/a-scaffold/setUri')
//根据uri自动生成对应的app与tpl的文件。
	function setUri(){
		var data = encodeURIComponent($("#uri").val());
		$.ajax({
			url:'/admin/a-scaffold/setUri',
			method:'post',
			data: "sys_ajax=1&data="+data,
			dataType:'json',
			success:function(json){
				if (json.success){
					$("#app_dirs").val(json.data.pwd);
					$("#tpl_dirs").val(json.data.pwd_tpl);
				}else {
					alert("失败："+json.msg);
				}
			},
			error:function(e){
				alert(e.responseText);
			}
			
		})
		
		
	}
	
	//如果文件不存在则自动生成一个app文件
	function mkApp(){
		var file_dir = encodeURIComponent($("#app_dirs").val());
		$.ajax({
			url:'/admin/a-scaffold/mkApp',
			method:'post',
			data: "sys_ajax=1&file_dir="+file_dir,
			dataType:'json',
			success:function(json){
				if (json.success){
					alert('成功：');
				}else {
					alert("失败："+json.msg);
				}
				$("#button_app_dirs").trigger('click');
			},
			error:function(e){
				alert(e.responseText);
			}
			
		});			
	}
	
	//如果文件不存在则自动生成一个tpl文件
	function mkTpl(){
		var file_dir = encodeURIComponent($("#tpl_dirs").val());
		$.ajax({
			url:'/admin/a-scaffold/mkTpl',
			method:'post',
			data: "sys_ajax=1&file_dir="+file_dir,
			dataType:'json',
			success:function(json){
				if (json.success){
					alert('成功：');
				}else {
					alert("失败："+json.msg);
				}
				$("#button_tpl_dirs").trigger('click');
			},
			error:function(e){
				alert(e.responseText);
			}
			
		});			
	}

</script>
</head>
<body>

<div >您当前所在的位置：<span >app管理</span>
</div>
<div class="clr"></div>

        <div class="mt10">
          <table id="ffc" cellpadding="0" cellspacing="0" class="t_stpi mb10" style= "table-layout:fixed ">
            <tr>
              <th width="50">名称</th>
              <th width="150">说明</th>
              <th width="350">值</th>
              <th width="350">操作</th>
            </tr>
            <tr>
              <td  align="center">uri</td>
              <td  align="center">restful风格的uri</td>
              <td  align="center">
                <input type="text" name="uri" id="uri" onblur="setUri();" size="50"/>
              </td> 
              <td  align="center">
                 
                 <input type="button" value="自动更新app" onclick="mkApp();"/>
                 <input type="button" value="自动更新tpl" onclick="mkTpl();"/>
              </td> 
            </tr>
            
            <tr>
              <td  align="center">app文件</td>
              <td  align="center">默认位置是web/app下的相对文件</td>
              <td align="center"> 
                    <input type="text" name="app_dirs" id="app_dirs" size="50"/>
              </td>
              <td  align="center">
                <input type="button" id="button_app_dirs" onclick="ajax_thickbox_json($('#app_dirs').val(),'/admin/a-scaffold/lookFile',0)" value="查看文件"/>
              </td> 
            </tr>
            
            <tr>
              <td  align="center">tpl文件</td>
              <td  align="center">默认位置是web/tpl下的相对文件</td>
              <td align="center"> 
                  <input type="text" name="tpl_dirs" id="tpl_dirs" size="50"/>
              </td>
              <td  align="center">
                <input type="button" id="button_tpl_dirs" onclick="ajax_thickbox_json($('#tpl_dirs').val(),'/admin/a-scaffold/lookFile',0)" value="点击查看"/>
              </td> 
            </tr>
            
          </table>          
          <div align="center">{pager}</div>          
        </div>

</body>
</html>
